package zh.demo.webuser.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import zh.demo.commons.utils.R;
import zh.demo.commons.utils.RedisUtils;
import zh.demo.webuser.annotation.LoginUser;
import zh.demo.webuser.model.UserEntity;
import zh.demo.webuser.model.WechatArticleCollectEntity;
import zh.demo.webuser.service.TokenService;
import zh.demo.webuser.service.WebUserService;
import zh.demo.webuser.service.WechatArticleCollectService;

/**
 *  用户操作相关的接口
 *  Created by WDJ on 2017/10/25.
 */
@RestController
@RequestMapping("/api")
public class UserActionController {

    @Autowired
    private WebUserService userService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private RedisUtils redisUtils;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Autowired
    private WechatArticleCollectService wechatArticleCollectService;

    private final ResourceLoader resourceLoader;

    @Autowired
    public UserActionController(ResourceLoader resourceLoader) {
        this.resourceLoader = resourceLoader;
    }

    @PostMapping("/wechatArticleCollect")
    public R wechatArticleCollect(@LoginUser UserEntity user,@RequestBody WechatArticleCollectEntity wechatArticleCollectEntity) {
        wechatArticleCollectEntity.setTbUserId(user.getUserId());
        wechatArticleCollectService.save(wechatArticleCollectEntity);

        return R.ok().put("msg","成功收藏!");
    }


























}
